--Api 表
/*
select * from SYS_Apis
select * from SYS_ApiM --M  Memo Main Manage

ReturnType
返回类型（类似返回值）
1 execSql 
2 openSql
3 execProc(不带返回结果) 
4 openProc(带返回结果集)
5 getList (使用getList sql 模板)
*/

declare 
  @ApiName varchar(50)='sjjd.moveTo',
  @ReturnType int =5
--
--
delete from SYS_Apis where ApiName=@ApiName
delete from SYS_ApiM where apiName=@ApiName
insert into SYS_ApiM([apiName],[name],[memo])
select @ApiName,'移动至审计阶段','移动至审计阶段 底稿平台中使用'
insert into SYS_Apis(ApiName,paramsLen,params,ReturnType,sqlText)
select @ApiName,0,
null,
@ReturnType,
'### 如果传了jdid说明，不显示这个阶段及子阶段
#if(jdid)
with t(jdid) as (
 select jdid from [#(dbname)]..sjjd where JDID=#para(jdid)
 union all
 select jd.jdid from [#(dbname)]..sjjd as jd,t where jd.dgnd + jd.pjdmc = t.jdid
)
#end
select jdid as id,dgnd+pjdmc pid,jdmc,dgnd from [#(dbname)]..sjjd where isnull(isdeleted,0)=0 and dgnd=#para(dgnd)
#if(jdid)
 and jdid not in(select jdid from t)
#end
order by id'